
#pragma once
#ifndef WINTHREAD
#define WINTHREAD
#include <Windows.h>


#include "BaseEngine.h"

class Win32UpdateCell : public UpdateCell
{
public :
	Win32UpdateCell(){}
	~Win32UpdateCell(){}
public :
	virtual bool OnUpdate(double NowTime,double PastTime);
};

class Win32RenderCell : public RenderCell
{
public :
	Win32RenderCell(){}
	~Win32RenderCell(){}
public :
	virtual bool OnWork();
};

typedef unsigned int (WINAPI *THREA_PORCEDURE) (LPVOID p_param);
unsigned int WINAPI WinThreadProc( LPVOID lpParameter );

class WinThreadWorker : public ThreadWorker
{
public :
	WinThreadWorker();
	~WinThreadWorker();
public :
	virtual bool Init();
	//bool Init();
	//void ThreadWorkerRun();
	virtual bool StartWork();
	virtual bool StopWork();
	virtual bool KillMyself();
	virtual bool OnInit(void* pParemeter = NULL);
	//virtual bool OnEvent();
	virtual bool OnWork();
	virtual bool OnWorkFinished();
	virtual void OnThreadEvent();
	virtual void OnThreadState();
	virtual void AddSignalEvent(ThreadEvent* pEvent);
	virtual bool Release(){return true;}

public :
	HANDLE m_ThreadWorkBenginEvent;
	HANDLE m_ThreadWorkFinshedEvent;
	HANDLE m_ThreadWorkSemaphore;
};



class WinThreadControler : public ThreadControler
{ 
public :
	WinThreadControler(){}
	~WinThreadControler(){}

public :
	virtual bool Initialize();
	bool InitThread(ThreadWorker* thread);
	virtual int  GetSuitableThreadCounts();
	virtual bool CreateSuitableThreadModle();
	virtual bool Work();
	virtual void CheckSynFinish();
	virtual bool Release(){return true;}

protected :

};


#endif